<?php
    class Tips extends CActiveRecord
    {
        public static function model($className = __CLASS__) {
            return parent::model ( $className );
        }

        public function tableName() {                  
            return 'c_system_news';
        }
        
        public function getNewsTipsOnTop($limit,$type){
            $str_order = " ORDER BY create_date DESC";
            $sql = "SELECT * FROM c_system_news WHERE type =0 AND status=1 ".$str_order." LIMIT ".$limit;
            $command = Yii::app()->db->createCommand($sql);
            $rows = $command->queryAll();        
            return $rows; 
        }
        public function getTipsOnBottom($limit,$type){
            $str_order = " ORDER BY create_date DESC";
            $sql = "SELECT * FROM c_system_news WHERE type =1 AND status=1 ".$str_order." LIMIT ".$limit;
            $command = Yii::app()->db->createCommand($sql);
            $rows = $command->queryAll();        
            return $rows; 
        }
        public function getTipsById($id){
            $sql = "SELECT * FROM c_system_news WHERE id =".$id;
            $command = Yii::app()->db->createCommand($sql);
            $row = $command->queryRow();        
            return $row; 
        }
    }
?>

